C=[1 0 1 0 0 1];
X=[1 0 1 0 0 0];
%h=6;
%M=0;
%mod2=[0 1;1 0];
%--------------------------------------------------------------------------------

for j=1:1:500;
XX(1)=mod2(mod2(mod2(C(1)*X(1)+1,C(2)*X(2)+1)+1,mod2(C(3)*X(3)+1,C(4)*X(4)+1)+1)+1,mod2(C(5)*X(5)+1,C(6)*X(6)+1)+1);
XX(2)=X(1);
XX(3)=X(2);
XX(4)=X(3);
XX(5)=X(4);
XX(6)=X(5);

X=XX;
M2(j)=X(h);
end;
%--------------------------------------------------------------------------------
N=50;  S=0;
for mu=0:1:N-1;
for n=1:1:N;
S=S+M(n)*M2(n-mu+310);
end;
Rv(mu+1)=S/N;
S=0;
end;
fic3=figure;
grid on;
plot(Rv);
pause;
close(fic3);